<?php
/**
 * 微信token类
 * User: narnia
 * Date: 2017/5/19
 * Time: 11:24
 */
namespace LancerWechat;
class WechatAccessToken extends WechatService
{
    public $key = 'accessToken';

    /**
     * 获取access_token
     */
    public function get()
    {
        $this->config['global']['appid'] = !isset($this->config['global']['appid']) && isset($this->config['global']['appID']) ? $this->config['global']['appID'] : $this->config['global']['appid'];
        $this->config['global']['appID'] = $this->config['global']['appid'];
        $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $this->config['global']['appid'] . '&secret=' . $this->config['global']['appsecret'] . '';
        $result = json_decode(\LancerWechat\WechatFunction::curl($url));
        if (isset($result->access_token) && $result->access_token) {
            $this->config['global']['access_token'] = $result->access_token;
        }
        return $result;
    }
}